/**
 * @file list.h
 * @author your name (you@domain.com)
 * @brief 
 * @version 0.1
 * @date 2023-08-20
 * 
 * @copyright Copyright (c) 2023
 * 
 */

#ifndef LIST_H
#define LIST_H

/******************************* Includes ********************************/
#include <stdio.h>
#include <stdlib.h>


#ifdef __cplusplus
extern "C"
{
#endif

/******************************* Macros ******************************/

#define LIST_E(...)  printf(__VA_ARGS__)
#define LIST_I(...)  printf(__VA_ARGS__)
#define LIST_D(...)  printf(__VA_ARGS__)

/******************************* Typedef ******************************/
typedef struct list_node
{
   void *data;   //malloc by list and auto release 
   int data_len;
   struct list_node *prev;
   struct list_node *next;

}list_node_t;
/******************************* Variables ******************************/
typedef void (*func_cb)(list_node_t *head, list_node_t *node);

/******************************* Functions ******************************/
void list_init(list_node_t *head);

int  list_add_node_tail(list_node_t *head, void *data, int data_len);

int  list_add_node_head(list_node_t *head, void *data, int data_len);

int  list_rm_node(list_node_t *head, list_node_t *node);

int  list_node_count(list_node_t *head);

void list_node_for_each(list_node_t *head, func_cb cb);

void list_node_for_each_reverse(list_node_t *head, func_cb cb);

void list_deinit(list_node_t *head);

#ifdef __cplusplus
}
#endif

#endif
/******************************* End of file ******************************/